<?php
include_once('database.php');
include_once('session_start.php');


$username = trim($_POST["UserName"]);


if(empty($username)){
	$_SESSION["H7_Library_Message"]="Du glemte at skrive hvilken bruger";
	header('Location:'.$_SERVER['HTTP_REFERER']);
	die;
}

$check = $db->query("SELECT UserName FROM users WHERE UserName = '".mysqli_real_escape_string($db,$username)."';");

if($check-> num_rows == 0){
	$_SESSION["H7_Library_Message"]="Brugeren ".htmlspecialchars($username)." findes ikke";
	header('Location:'.$_SERVER['HTTP_REFERER']);
	die;
}


$db ->query("DELETE FROM users WHERE UserName = '".mysqli_real_escape_string($db,$username)."';");

$_SESSION["H7_Library_Message"]="Brugeren ".htmlspecialchars($username)." er slettet";

header('Location:'.$_SERVER['HTTP_REFERER']);


?>